package cn.edu.wzu.openlearning.exception;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

@ControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler(value = Exception.class)
    public @ResponseBody
    String defaultErrorHandler(HttpServletRequest req, Exception e) throws Exception {

        return "ERROR:" + e + ",url="+ req.getRequestURL();
    }
}